%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/functions/computed-column-combined"
    Bucket0("Bucket 0 (root)<br /><br />1: 53, 58<br />ᐳ: 8, 9, 34, 57, 62, 67, 72, 10, 52<br />2: PgSelectInlineApply[63]<br />3: PgSelectInlineApply[68]<br />4: PgSelect[7]<br />ᐳ: Access[69]<br />5: PgSelectRows[12]<br />ᐳ: First[11], PgSelectSingle[13]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 69, 13<br /><br />ROOT PgSelectSingleᐸforumsᐳ[13]<br />1: <br />ᐳ: List[70], Lambda[71], Access[64]<br />2: PgSelectRows[21]<br />ᐳ: First[20], PgSelectSingle[22]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 22, 64<br /><br />ROOT PgSelectSingle{1}ᐸusersᐳ[22]<br />1: <br />ᐳ: 23, 24, 65, 66, 54, 59<br />2: PgSelectRows[32]<br />ᐳ: 31, 33, 60, 61"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 61, 54, 33<br /><br />ROOT PgSelectSingle{2}ᐸusers_most_recent_forumᐳ[33]<br />1: PgSelectRows[48]<br />ᐳ: List[55], Lambda[56]<br />2: PgSelectRows[42]<br />ᐳ: 41, 43, 44"):::bucket
    Bucket4("Bucket 4 (listItem)<br /><br />ROOT __Item{4}ᐸ48ᐳ[49]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 50<br /><br />ROOT PgSelectSingle{4}ᐸforums_featured_messagesᐳ[50]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5

    %% plan dependencies
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Constantᐸ'f1700000-0000-0000-0000-000000000f17'ᐳ[72]"]]:::plan
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgFromExpression67{{"PgFromExpression[67∈0] ➊"}}:::plan
    PgFromExpression62{{"PgFromExpression[62∈0] ➊"}}:::plan
    PgFromExpression52{{"PgFromExpression[52∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[34]"}}:::plan
    PgFromExpression57{{"PgFromExpression[57∈0] ➊"}}:::plan
    PgSelectInlineApply68["PgSelectInlineApply[68∈0] ➊"]:::plan
    Object10 & PgFromExpression67 & PgFromExpression62 & PgFromExpression52 & PgFromExpression57 & PgSelectInlineApply68 --> PgSelect7
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    PgSelectInlineApply63["PgSelectInlineApply[63∈0] ➊"]:::plan
    PgSelectInlineApply53["PgSelectInlineApply[53∈0] ➊"]:::plan
    PgSelectInlineApply58["PgSelectInlineApply[58∈0] ➊"]:::plan
    PgSelectInlineApply53 & PgSelectInlineApply58 --> PgSelectInlineApply63
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    First11{{"First[11∈0] ➊"}}:::plan
    PgSelectRows12[["PgSelectRows[12∈0] ➊"]]:::plan
    PgSelectRows12 --> First11
    PgSelect7 --> PgSelectRows12
    PgSelectSingle13{{"PgSelectSingle[13∈0] ➊<br />ᐸforumsᐳ"}}:::plan
    First11 --> PgSelectSingle13
    PgSelectInlineApply63 --> PgSelectInlineApply68
    Access69{{"Access[69∈0] ➊<br />ᐸ7.m.joinDetailsFor15ᐳ"}}:::plan
    PgSelect7 --> Access69
    List70{{"List[70∈1] ➊<br />ᐸ69,13ᐳ"}}:::plan
    Access69 & PgSelectSingle13 --> List70
    First20{{"First[20∈1] ➊"}}:::plan
    PgSelectRows21[["PgSelectRows[21∈1] ➊"]]:::plan
    PgSelectRows21 --> First20
    Lambda71{{"Lambda[71∈1] ➊<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda71 --> PgSelectRows21
    PgSelectSingle22{{"PgSelectSingle[22∈1] ➊<br />ᐸusersᐳ"}}:::plan
    First20 --> PgSelectSingle22
    Access64{{"Access[64∈1] ➊<br />ᐸ71.m.joinDetailsFor26ᐳ"}}:::plan
    Lambda71 --> Access64
    List70 --> Lambda71
    List60{{"List[60∈2] ➊<br />ᐸ59,31ᐳ"}}:::plan
    Access59{{"Access[59∈2] ➊<br />ᐸ66.m.subqueryDetailsFor45ᐳ"}}:::plan
    First31{{"First[31∈2] ➊"}}:::plan
    Access59 & First31 --> List60
    List65{{"List[65∈2] ➊<br />ᐸ64,22ᐳ"}}:::plan
    Access64 & PgSelectSingle22 --> List65
    PgClassExpression23{{"PgClassExpression[23∈2] ➊<br />ᐸ__forums_r...”username”ᐳ"}}:::plan
    PgSelectSingle22 --> PgClassExpression23
    PgClassExpression24{{"PgClassExpression[24∈2] ➊<br />ᐸ__forums_r...vatar_url”ᐳ"}}:::plan
    PgClassExpression23 o--o PgClassExpression24
    PgSelectRows32[["PgSelectRows[32∈2] ➊"]]:::plan
    PgSelectRows32 --> First31
    Lambda66{{"Lambda[66∈2] ➊<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda66 --> PgSelectRows32
    PgSelectSingle33{{"PgSelectSingle[33∈2] ➊<br />ᐸusers_most_recent_forumᐳ"}}:::plan
    First31 --> PgSelectSingle33
    Access54{{"Access[54∈2] ➊<br />ᐸ66.m.joinDetailsFor36ᐳ"}}:::plan
    Lambda66 --> Access54
    Lambda66 --> Access59
    Lambda61{{"Lambda[61∈2] ➊<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    List60 --> Lambda61
    List65 --> Lambda66
    List55{{"List[55∈3] ➊<br />ᐸ54,33ᐳ"}}:::plan
    Access54 & PgSelectSingle33 --> List55
    First41{{"First[41∈3] ➊"}}:::plan
    PgSelectRows42[["PgSelectRows[42∈3] ➊"]]:::plan
    PgSelectRows42 --> First41
    Lambda56{{"Lambda[56∈3] ➊<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda56 --> PgSelectRows42
    PgSelectSingle43{{"PgSelectSingle[43∈3] ➊<br />ᐸforums_unique_author_countᐳ"}}:::plan
    First41 --> PgSelectSingle43
    PgClassExpression44{{"PgClassExpression[44∈3] ➊<br />ᐸ__forums_u..._count__.vᐳ"}}:::plan
    PgSelectSingle43 --> PgClassExpression44
    PgSelectRows48[["PgSelectRows[48∈3] ➊"]]:::plan
    Lambda61 --> PgSelectRows48
    List55 --> Lambda56
    __Item49[/"__Item[49∈4]<br />ᐸ48ᐳ"\]:::itemplan
    PgSelectRows48 ==> __Item49
    PgSelectSingle50{{"PgSelectSingle[50∈4]<br />ᐸforums_featured_messagesᐳ"}}:::plan
    __Item49 --> PgSelectSingle50
    PgClassExpression51{{"PgClassExpression[51∈5]<br />ᐸ__forums_f...s__.”body”ᐳ"}}:::plan
    PgSelectSingle50 --> PgClassExpression51

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,First11,PgSelectRows12,PgSelectSingle13,PgFromExpression52,PgSelectInlineApply53,PgFromExpression57,PgSelectInlineApply58,PgFromExpression62,PgSelectInlineApply63,PgFromExpression67,PgSelectInlineApply68,Access69 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,First20,PgSelectRows21,PgSelectSingle22,Access64,List70,Lambda71 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression23,PgClassExpression24,First31,PgSelectRows32,PgSelectSingle33,Access54,Access59,List60,Lambda61,List65,Lambda66 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,First41,PgSelectRows42,PgSelectSingle43,PgClassExpression44,PgSelectRows48,List55,Lambda56 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,__Item49,PgSelectSingle50 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression51 bucket5

